using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class vExpired_Item_ControlMap : EntityTypeConfiguration<vExpired_Item_Control>
    {
        public vExpired_Item_ControlMap()
        {
            // Primary Key
            this.HasKey(t => new { t.ITEM, t.DESC, t.Expirydate, t.TypeId, t.TypeName, t.CategId, t.CategName, t.Company });

            // Properties
            this.Property(t => t.ITEM)
                .IsRequired()
                .HasMaxLength(10);

            this.Property(t => t.DESC)
                .IsRequired()
                .HasMaxLength(250);

            this.Property(t => t.Location)
                .HasMaxLength(6);

            this.Property(t => t.TypeId)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.TypeName)
                .IsRequired()
                .HasMaxLength(25);

            this.Property(t => t.CategId)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.CategName)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.vendSrh)
                .HasMaxLength(6);

            this.Property(t => t.Vendor)
                .HasMaxLength(35);

            this.Property(t => t.Company)
                .IsRequired()
                .HasMaxLength(33);

            // Table & Column Mappings
            this.ToTable("vExpired_Item_Control");
            this.Property(t => t.ITEM).HasColumnName("ITEM");
            this.Property(t => t.DESC).HasColumnName("DESC");
            this.Property(t => t.ONHAND).HasColumnName("ONHAND");
            this.Property(t => t.Location).HasColumnName("Location");
            this.Property(t => t.Expirydate).HasColumnName("Expirydate");
            this.Property(t => t.TypeId).HasColumnName("TypeId");
            this.Property(t => t.TypeName).HasColumnName("TypeName");
            this.Property(t => t.CategId).HasColumnName("CategId");
            this.Property(t => t.CategName).HasColumnName("CategName");
            this.Property(t => t.vendSrh).HasColumnName("vendSrh");
            this.Property(t => t.Vendor).HasColumnName("Vendor");
            this.Property(t => t.Company).HasColumnName("Company");
        }
    }
}
